package poly2;

public class Demo {
    public static void main(String[] args) {
        //以多态形式创建对象
        Animal animal = new Shark();
        animal.eat();
        //animal.weight //编译报错
        //animal.diving();

        animal = new Cat();
        animal.eat();
        //animal.age
        //animal.catchMouse();
    }
}


interface Animal{
    public abstract void eat();
}

class Shark implements Animal{

    int weight;

    @Override
    public void eat() {
        System.out.println("鲨鱼吃人~");
    }

    public void diving(){
        System.out.println("潜水~");
    }
}

class Dog implements Animal{

    String name;

    @Override
    public void eat() {
        System.out.println("狗吃骨头~");
    }

    public void swim(){
        System.out.println("狗刨~");
    }
}

class Cat implements Animal{

    int age;

    @Override
    public void eat() {
        System.out.println("猫吃罐头~");
    }

    public void catchMouse(){
        System.out.println("猫抓老鼠~");
    }
}
